/* eslint-disable eqeqeq */
/* eslint-disable eqeqeq */
<template>
<div class="login-container">
    <el-form
      :model="loginForm"
      ref="loginForm"
      label-position="left"
      label-width="0px"
      class="card-box login-form">
      <h3 class="title">系统注册</h3>
      <el-form-item prop="username">
        <span class="svg-container svg-container_login">
         <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-zhanghao"></use></svg>
        </span>
        <el-input v-model="loginForm.username" placeholder="请输入账户"  clearable/>
      </el-form-item>
      <el-form-item prop="password">
        <span class="svg-container">
         <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-icon_password"></use></svg>
        </span>
        <el-input
          type="password"
          @keyup.enter.native="register"
          v-model="loginForm.password"
          placeholder="请输入密码"  clearable
        ></el-input>
      </el-form-item>
      <el-form-item prop="name">
        <span class="svg-container">
         <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-zhenshixingming"></use></svg>
        </span>
        <el-input
          type="text"
          @keyup.enter.native="register"
          v-model="loginForm.name"
          placeholder="真实姓名"  clearable
        ></el-input>
      </el-form-item>
      <el-form-item prop="phone">
        <span class="svg-container">
         <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-shouji"></use></svg>
        </span>
        <el-input
          type="text"
          @keyup.enter.native="register"
          v-model="loginForm.phone"
          placeholder="手机号码"  clearable
        ></el-input>
      </el-form-item>
      <el-form-item prop="email">
        <span class="svg-container">
         <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-youxiang"></use></svg>
        </span>
        <el-input
          type="text"
          @keyup.enter.native="register"
          v-model="loginForm.email"
          placeholder="邮箱"  clearable
        ></el-input>
      </el-form-item>
      <span style="font-size:6px;">已有账号?去<a href="./login" style="color:red;">登录</a></span>
      <el-form-item style="margin-top:10px;">
        <el-button
          type="primary"
          style="width:90%;margin:0px 0px 0px 20px;"
          v-on:click="register">
          注册
        </el-button>
      </el-form-item>
       <p style="color: block;text-align: center;font-size: 6px;">
          Copyright ©2020-2020 辰鬼丫
          </p>
           <p style="color: block;text-align: center;">
            <em><a href="https://beian.miit.gov.cn/" style="color: block; text-decoration:none;
            font-size: 6px;" target="_black">湘ICP备2020016792号</a></em>
          </p>
    </el-form>

    <!-- cnpm install vue-particles --save-dev
        import VueParticles from 'vue-particles'
        Vue.use(VueParticles)
    -->
    <!-- 粒子
    <vue-particles
      color="#66B1FF"
      :particleOpacity="0.7"
      :particlesNumber="90"
      shapeType="circle"
      :particleSize="4"
      linesColor="#dedede"
      :linesWidth="1"
      :lineLinked="true"
      :lineOpacity="0.4"
      :linesDistance="150"
      :moveSpeed="3"
      :hoverEffect="true"
      hoverMode="grab"
      :clickEffect="true"
      clickMode="push"
    >
      <!-- color: String类型。默认'#dedede'。粒子颜色。
          particleOpacity: Number类型。默认0.7。粒子透明度。
          particlesNumber: Number类型。默认80。粒子数量。
          shapeType: String类型。默认'circle'。可用的粒子外观类型有："circle","edge","triangle", "polygon","star"。
          particleSize: Number类型。默认80。单个粒子大小。
          linesColor: String类型。默认'#dedede'。线条颜色。
          linesWidth: Number类型。默认1。线条宽度。
          lineLinked: 布尔类型。默认true。连接线是否可用。
          lineOpacity: Number类型。默认0.4。线条透明度。
          linesDistance: Number类型。默认150。线条距离。
          moveSpeed: Number类型。默认3。粒子运动速度。
          hoverEffect: 布尔类型。默认true。是否有hover特效。
          hoverMode: String类型。默认true。可用的hover模式有: "grab", "repulse", "bubble"。
          clickEffect: 布尔类型。默认true。是否有click特效。
      clickMode: String类型。默认true。可用的click模式有: "push", "remove", "repulse", "bubble"
    </vue-particles> -->
  </div>
</template>
<script>
  export default{
    data () {
      return {
        checked: true,
        loginForm: {
          username: '',
          password: '',
          name: '',
          phone: '',
          email: ''
        }
      }
    },
    components: {
      
    },
    methods: {
      register () {
        if (!this.loginForm.username) {
        this.$message.warning('请输入账号')
            return
        }
        if (!this.loginForm.password) {
            this.$message.warning('请输入密码')
            return
        }
        if (this.loginForm.password.length < 6) {
            this.$message.warning('密码长度不能小于六位')
            return
        }
        if (!this.loginForm.name) {
            this.$message.warning('真实姓名不能为空')
            return
        }
        if (!this.loginForm.phone) {
            this.$message.warning('手机号码不能为空')
            return
        }
         if (!(/^1[3456789]\d{9}$/.test(this.loginForm.phone))) {
             this.$message.warning('手机号码格式不正确')
             return
         }
         if (!(/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.loginForm.email))) {
             this.$message.warning('邮箱格式不正确')
             return
         }

        var _this = this
        this.$axios
          .post('/register', {
            username: this.loginForm.username,
            password: this.loginForm.password,
            name: this.loginForm.name,
            phone: this.loginForm.phone,
            email: this.loginForm.email
          })
          .then(resp => {
            if (resp.data.code === 200) {
             this.$message.success('注册成功')
              _this.$router.replace('/login')
            } else {
               this.$message.warning(resp.data.message)
            }
          })
          .catch(failResponse => {})
      }
    }
  }
</script>
<style rel="stylesheet/scss" lang="scss">
@import "../styles/mixin.scss";
$bg: #1e9fff;
$dark_gray: black;
$light_gray: black;

.card-box{
  border-radius: 10%;
  background-color: #fff;
}
.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
  font-size: 18px;
}
.login-container {
  @include relative;
  height: 100vh;
  background-color: $bg;
  input:-webkit-autofill {
    -webkit-text-fill-color: #fff !important;
  }
  input {
    background: transparent;
    border: 0px;
    -webkit-appearance: none;
    border-radius: 0px;
    padding: 12px 5px 12px 15px;
    color: $light_gray;
    height: 47px;
  }
  .el-input {
    display: inline-block;
    height: 47px;
    width: 85%;
  }
  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;
  }
  .svg-container {
    padding: 6px 5px 6px 15px;
    color: $dark_gray;
    vertical-align: middle;
    width: 30px;
    display: inline-block;
    &_login {
      font-size: 20px;
    }
  }
  .title {
    font-size: 26px;
    color: $light_gray;
    margin: 0px auto 30px 0px;
    text-align: center;
    font-weight: bold;
  }
  .login-form {
    position: absolute;
    left: 0;
    right: 0;
    width: 400px;
    padding: 35px 35px 15px 35px;
    margin: 120px auto;
  }
  .el-form-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: white;
    border-radius: 5px;
    color: white;
    width: 91%;
  }
  .show-pwd {
    position: absolute;
    right: 10px;
    top: 7px;
    font-size: 16px;
    color: $dark_gray;
    cursor: pointer;
  }
  .thirdparty-button {
    position: absolute;
    right: 35px;
    bottom: 28px;
  }
}
</style>
